package com.example.smart_city_0829.activity.youth_lnn;

import android.webkit.WebView;
import android.widget.TextView;

import com.example.smart_city_0829.R;
import com.example.smart_city_0829.base.BaseActivity;
import com.example.smart_city_0829.entity.YouthInn.PolicyDetail;
import com.example.smart_city_0829.retrofit.NetCallBack;

import retrofit2.Call;
import retrofit2.Response;

public class PolicyDetailActivity extends BaseActivity {

    private int id = -1;

    private TextView title;
    private TextView pubMan;
    private TextView time;
    private WebView web;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_policy_detail;
    }

    @Override
    protected void initView() {

        title = (TextView) findViewById(R.id.title);
        pubMan = (TextView) findViewById(R.id.pub_man);
        time = (TextView) findViewById(R.id.time);
        web = (WebView) findViewById(R.id.web);
    }

    @Override
    protected void initData() {
        id = getIntent().getIntExtra("id",-1);

        api.getPolicyDetail(id).enqueue(new NetCallBack<PolicyDetail>() {
            @Override
            public void onResponse(Call<PolicyDetail> call, Response<PolicyDetail> response) {
                final PolicyDetail.DataBean data = response.body().getData();
                title.setText(data.getTitle());
                pubMan.setText(data.getAuthor());
                time.setText(data.getCreateTime());
                web.loadDataWithBaseURL(null,data.getContent(),null,"utf-8",null);
            }
        });
    }

    @Override
    protected void initEvent() {

    }

    @Override
    protected String getActionBarTitle() {
        return "政策详情";
    }
}